<template>
	<el-dialog v-model="dialogVisible" append-to-body :show-close="false" :close-on-click-modal="false"
		class="flex-align" style="width: 100%;height: 100%;padding: 30px 24px;margin: 0;background: transparent;">
		<template #header>
			<el-card style="width: 100%;height: 100%;" body-style="padding: 0;" shadow="never">
				<template #header>
					<div class="flex-space-between">
						<div>
							<el-text style="font-size: 16px;">
								退货单
							</el-text>
						</div>
						<div>
							<el-button @click="closeDialog">取消</el-button>
							<!-- <el-button @click="closeDialog">
								保存并继续创建
								<el-icon style="margin-left: 4px;">
									<ArrowDown />
								</el-icon>
							</el-button> -->
							<el-button type="primary" @click="submitForm(vFormRef)">
								保存
							</el-button>
						</div>
					</div>
				</template>
				<el-scrollbar ref="scrollbarRef" @scroll="handleScroll"
					:style="`height: calc(100vh - 69px - ( 30px + 30px));`">
					<el-form :model="formData" :rules="rules" ref="vFormRef" label-position="top" label-width="50px"
						style="padding: 16px;">
						<el-form-item label="退货状态" prop="returnStatusId">
							<el-input v-model="formData.returnStatusId" readonly type="text" clearable class="my">
								<template #prefix>
									<div>
										<el-check-tag
											:style="`color: ${returnStatusIndex===key?'#fff':''};${returnStatusIndex===key?`background: ${item.bg}`:''}`"
											v-for="(item,key) in returnStatusTags" :key="key"
											:checked="returnStatusIndex===key"
											@change="tagChange(key,'returnStatusId')">{{item.text}}</el-check-tag>
									</div>
								</template>
							</el-input>
						</el-form-item>
						<el-form-item label="客户" prop="customer">
							<el-select @clear="selectClear('customer')" v-model="formData.customer"
								@change="(value:any)=>selectChange(value,'customer')" multiple ref="customer" clearable>
								<el-option v-for="item in customerOption" :key="key" :label="item?.label"
									:value="item?.value">
									<!--  -->
									<div class="flex-align-center">
										<el-icon :color="item?.color">
											<component :is="item?.icon"></component>
										</el-icon>
										<!--  -->
										<el-text style="margin-left: 6px;">{{item?.label}}</el-text>
									</div>
								</el-option>
								<!--  -->
								<template #tag>
									<div style="padding-left: 6px;">
										<div>
											<div class="flex-align-center">
												<el-icon :color="customerOption[customerIndex]?.color">
													<component :is="customerOption[customerIndex]?.icon">
													</component>
												</el-icon>
												<!--  -->
												<el-text size="small"
													style="margin-left: 6px;">{{customerOption[customerIndex]?.label}}</el-text>
											</div>
										</div>
									</div>
								</template>
							</el-select>
						</el-form-item>
						<el-row :gutter="16">
							<el-col :span="!formData.returnStatusId?24:formData.returnStatusId===134?12:24">
								<el-form-item label="退货订单" prop="order">
									<el-select @clear="selectClear('order')" v-model="formData.order"
										@change="(value:any)=>selectChange(value,'order')" multiple ref="order" clearable>
										<el-option v-for="item in orderOption" :key="key" :label="item?.label"
											:value="item?.value">
											<!--  -->
											<div class="flex-align-center">
												<el-icon :color="item?.color">
													<component :is="item?.icon"></component>
												</el-icon>
												<!--  -->
												<el-text style="margin-left: 6px;">{{item?.label}}</el-text>
											</div>
										</el-option>
										<!--  -->
										<template #tag>
											<div style="padding-left: 6px;">
												<div>
													<div class="flex-align-center">
														<el-icon :color="orderOption[orderIndex]?.color">
															<component :is="orderOption[orderIndex]?.icon">
															</component>
														</el-icon>
														<!--  -->
														<el-text size="small"
															style="margin-left: 6px;">{{orderOption[orderIndex]?.label}}</el-text>
													</div>
												</div>
											</div>
										</template>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="formData.returnStatusId===134?12:0">
								<el-form-item label="入库订单" prop="inboundOrder">
									<el-select @clear="selectClear('inboundOrder')" v-model="formData.inboundOrder"
										@change="(value:any)=>selectChange(value,'inboundOrder')" multiple ref="inboundOrder" clearable>
										<el-option v-for="item in inboundOrderOption" :key="key" :label="item?.label"
											:value="item?.value">
											<!--  -->
											<div class="flex-align-center">
												<el-icon :color="item?.color">
													<component :is="item?.icon"></component>
												</el-icon>
												<!--  -->
												<el-text style="margin-left: 6px;">{{item?.label}}</el-text>
											</div>
										</el-option>
										<!--  -->
										<template #tag>
											<div style="padding-left: 6px;">
												<div>
													<div class="flex-align-center">
														<el-icon :color="inboundOrderOption[inboundOrderIndex]?.color">
															<component :is="inboundOrderOption[inboundOrderIndex]?.icon">
															</component>
														</el-icon>
														<!--  -->
														<el-text size="small"
															style="margin-left: 6px;">{{inboundOrderOption[inboundOrderIndex]?.label}}</el-text>
													</div>
												</div>
											</div>
										</template>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="16">
							<el-col :span="8">
								<el-form-item label="退货申请日期" prop="returnApplicationDate">
									<el-date-picker v-model="formData.returnApplicationDate" style="width:100%;"
										type="date" />
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="退货审批完成日期" prop="returnApprovalCompletionDate">
									<el-date-picker v-model="formData.returnApprovalCompletionDate" style="width:100%;"
										type="date" />
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item label="申请人" prop="applicant">
									<el-input type="text" readonly v-model="formData.applicant" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="16">
							<el-col :span="12">
								<el-form-item label="退货原因" prop="reasonReturnId">
									<el-input v-model="formData.reasonReturnId" readonly type="text" clearable
										class="my">
										<template #prefix>
											<div>
												<el-check-tag
													:style="`color: ${reasonReturnIndex===key?'#fff':''};${reasonReturnIndex===key?`background: ${item.bg}`:''}`"
													v-for="(item,key) in reasonReturnTags" :key="key"
													:checked="reasonReturnIndex===key"
													@change="tagChange(key,'reasonReturnId')">{{item.text}}</el-check-tag>
											</div>
										</template>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="备注" prop="remark">
									<el-input type="text" v-model="formData.remark" clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="16">
							<el-col :span="12">
								<el-form-item label="应退款总额" prop="totalRefundAmount">
									<el-input placeholder="自动计算结果" type="number" v-model="formData.totalRefundAmount" disabled
										clearable></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="退货总数" prop="totalReturnQuantity">
									<el-input placeholder="自动计算结果" type="number" v-model="formData.totalReturnQuantity" disabled
										clearable></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-form-item label="退货负提成" prop="negativeCommission">
							<el-input placeholder="自动计算结果" type="number" v-model="formData.negativeCommission" disabled clearable></el-input>
						</el-form-item>
						<el-form-item>
							<el-input type="text" ref="salesPerson" readonly clearable class="my1">
								<template #prefix>
									<div style="margin: 0;padding: 0;">
										<el-tabs v-model="activeName" @tab-click="handleClick" class="my">
											<el-tab-pane label="退货明细" name="order">
												<div class="flex-space-between"
													style="height: 48px;padding-left: 10px;">
													<el-text type="info" size="small">
														来自 <el-text type="primary" size="small">退货明细</el-text> 的数据
														共1条
													</el-text>
													<el-text>
														<el-tooltip effect="light" :hide-after="50" content="创建"
															placement="top">
															<div class="my-a" @click="setTableData">
																<el-icon size="16px" color="#409EFF">
																	<CirclePlus />
																</el-icon>
															</div>
														</el-tooltip>
													</el-text>
												</div>
												<!--  -->
												<el-scrollbar style="width: calc(100vw - 48px - 32px);height: 300px;">
													<el-table @cell-dblclick="tableCellClick" v-loading="loading"
														:data="tableData" :stripe="false" table-layout="auto"
														:default-sort="{}" border style="width: 100%;height: 300px;"
														class="my">
														<el-table-column width="76" fixed="left" prop="id"
															:sortable="false">
															<template #default="scope">
																<el-tooltip effect="light" :hide-after="50" content="复制"
																	placement="top">
																	<el-button style="padding: 0;" class="my"
																		@click="copyTableData(scope.$index)"
																		:icon="DocumentAdd"></el-button>
																</el-tooltip>
																<el-tooltip effect="light" :hide-after="50" content="删除"
																	placement="top">
																	<el-button style="padding: 0;" class="my"
																		@click="deleteTableData(scope.$index)"
																		:icon="Delete"></el-button>
																</el-tooltip>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="orderDetailId" label="退货订单明细*(可选)"
															:sortable="false">
															<template #default="scope">
																<div class="flex-align-center"
																	v-if="scope.row.orderDetail">
																	<el-icon
																		:color="scope.row.orderDetail?.color || '#82b51b'">
																		<component
																			:is="scope.row.orderDetail?.icon || CopyDocument">
																		</component>
																	</el-icon>
																	<el-text size="small" style="margin-left: 6px;">
																		{{scope.row.orderDetail?.label || `${scope.row.orderDetail?.salesOrder?.orderNumber}_${scope.row.product?.productName + scope.row.product?.model}`}}
																	</el-text>
																</div>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="quantityOrdered" label="下单数量"
															:sortable="false">
															<template #default="scope">
																<el-text>{{scope.row?.quantityOrdered || scope.row?.orderDetail?.quantityOrdered}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="pendingShipmentQuantity"
															label="待申请发货数量" :sortable="false">
															<template #default="scope">
																<el-text>{{scope.row?.pendingShipmentQuantity || scope.row?.orderDetail?.pendingShipmentQuantity}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="shippedQuantity"
															label="已发货数量" :sortable="false">
															<template #default="scope">
																<el-text>{{scope.row?.shippedQuantity || scope.row?.orderDetail?.shippedQuantity}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="productId" label="退货产品"
															:sortable="false">
															<template #default="scope">
																<div class="flex-align-center"
																	v-if="scope.row.products">
																	<el-icon
																		:color="scope.row.products?.color || '#82b51b'">
																		<component
																			:is="scope.row.products?.icon || UploadFilled">
																		</component>
																	</el-icon>
																	<el-text size="small" style="margin-left: 6px;">
																		{{scope.row.products?.productName}}{{scope.row.products?.model}}
																		| {{scope.row.products?.d2Label}}
																	</el-text>
																</div>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="sellingPrice" label="销售单价"
															:sortable="false">
															<template #default="scope">
																<el-text>{{scope.row?.products?.sellingPrice || scope.row?.product?.sellingPrice}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="returnQuantity"
															label="本次退货数量*(可选)" :sortable="false">
															<template #default="scope">
																<el-text>{{scope.row.returnQuantity}}</el-text>
															</template>
														</el-table-column>
														<el-table-column width="140" prop="returnPrice" label="退货单价*(可选)"
															:sortable="false">
															<template #default="scope">
																<el-text>{{scope.row.returnPrice}}</el-text>
															</template>
														</el-table-column>
													</el-table>
												</el-scrollbar>
											</el-tab-pane>
										</el-tabs>
									</div>
								</template>
							</el-input>
						</el-form-item>
					</el-form>
				</el-scrollbar>
				<!--  -->
			</el-card>
			<!--  -->
			<levitation ref="levitationRef" :option="selectCell.option" :types="types" :st_type="selectCell.type"
				:params="levitationParams" :observerElement="scrollbarRef" :element="element" @change="levitationChange"
				@blur="levitationBlur" />
		</template>
	</el-dialog>
</template>

<script setup lang="ts">
	import { reactive, ref } from 'vue';
	import { useRoute, useRouter } from 'vue-router';
	import request from '../../../utils/request';
	import { UploadFilled, UserFilled, WalletFilled, CirclePlus, DocumentAdd, Delete, CopyDocument } from '@element-plus/icons-vue';
	import { mergeObjects, formatNumber } from '../../../utils';
	import { useSelect } from '../../../utils/mixins';
	import levitation from '../../../components/levitation-form/levitation-form.vue';
	import { getShipments } from '../../../api/shipmentAPI';
	import { ElMessage, FormInstance } from 'element-plus';
	import { jwtDecode } from 'jwt-decode';
	import cookie from 'js-cookie';
	const emits = defineEmits(['update']);
	const { handSelectChange } = useSelect();
	const router = useRouter();
	const route = useRoute();
	const vFormRef = ref(null);
	const loading = ref(false);
	const activeName = ref('order');
	//levitation start
	const element = ref(null);
	const levitationRef = ref(null);
	const scrollbarRef = ref(null);
	const types = ref('');
	const selectCell = ref({
		id: 0,
		property: '',
		type: '',
		option: []
	});
	const levitationParams = ref(null);
	//levitation end

	// 表单
	const formData = ref({
		returnStatusId: null,
		customer: [],
		customerId: null,
		order: [],
		orderId: null,
		inboundOrder:[],
		inboundOrderId:null,
		returnApplicationDate: null,
		returnApprovalCompletionDate: null,
		applicant: null,
		reasonReturnId: null,
		remark: null,
		totalRefundAmount: null,
		totalReturnQuantity: null,
		negativeCommission: null,
	});
	//验证
	const rules = reactive({
		returnStatusId: [{ required: true, message: '退货状态必选！', trigger: ['blur', 'change'] }],
		customer: [{ required: true, message: '客户必选！', trigger: ['blur', 'change'] }],
		order: [{ required: true, message: '退货订单必选！', trigger: ['blur', 'change'] }],
		returnApplicationDate: [{ required: true, message: '退货申请日期！', trigger: ['blur', 'change'] }],
		returnApprovalCompletionDate: [],
		applicant: [{ required: true, message: '申请人必填！', trigger: ['blur', 'change'] }],
		reasonReturnId: [{ required: true, message: '退货原因必选！', trigger: ['blur', 'change'] }],
		remark: [],
		totalRefundAmount: [],
		totalReturnQuantity: [],
		negativeCommission: [],
	});
	const pageData = ref({
		pageNum: 1,
		pageSize: 1000,
		total: 0,
		pages: 0,
	});
	const tableData = reactive([]);
	//退货状态
	const returnStatusTags = ref([]);
	const returnStatusIndex = ref(-1);
	//客户
	const customerOption = ref([]);
	const customerIndex = ref(-1);
	const customer = ref(null);
	//退货订单
	const orderOption = ref([]);
	const orderIndex = ref(-1);
	const order = ref(null);
	//入库订单
	const inboundOrderOption = ref([]);
	const inboundOrderIndex = ref(-1);
	const inboundOrder = ref(null);
	//退货原因
	const reasonReturnTags = ref([]);
	const reasonReturnIndex = ref(-1);
	//退货订单明细
	const orderDetailOption = ref([]);
	//退货产品
	const productOption = ref([]);
	//
	const dialogVisible = ref(false);
	/**
	 * 打开弹出层
	 */
	const openDialog = () => {
		dialogVisible.value = true;
		setTimeout(async () => {
			const result = await getPageId();
			//
			if (result) {
				getReturnStatusList();
				getCustomerList();
				getReasonReturnList();
				if(!route.query.id){
					returnStatusIndex.value = 0;
					formData.value.returnStatusId = 130;
				}
			}
		}, 10);
	}
	/**
	 * 关闭弹出层
	 */
	const closeDialog = () => {
		dialogVisible.value = false;
		vFormRef.value.resetFields();
		//清空url参数
		router.push({ query: {} });
	}
	//获取当前页面的数据
	const getPageId = async () => {
		if (!route.query.id) {
			const token = cookie.get('token');
			const decodedToken : {
				username : string
			} = jwtDecode(token);
			// console.log('decodedToken--->', decodedToken);
			//
			formData.value.applicant = decodedToken?.username;
			//
			return true;
		}
		//清空
		tableData.splice(0,tableData.length);
		const result = await request({
			url: '/login/selectSalesReturnById',
			params: {
				id: route.query.id
			},
		});
		//
		console.log('getPageId --->', result);
		formData.value = result.data.t;
		//
		tableData.push(...result.data.t.returnDetails);
		return true;
	}
	//设置一个
	const setTableData = () => {
		tableData.push({
			id: +new Date(),
			productId: null,
			sellingPrice: null,
			returnQuantity: null,
			returnPrice: null,
			orderDetailId: null,
			quantityOrdered: null,
			pendingShipmentQuantity: null,
			shippedQuantity: null,
			orderDetail: null,
			products: null
		});
	}
	//复制一个
	const copyTableData = (index : number) => {
		//...
		const item = { ...tableData[index] };
		item.id = +new Date();
		tableData.push(item);
	}
	//删除一个
	const deleteTableData = (index : number) => {
		tableData.splice(index, 1);
	}
	const selectClear = (type : string) => {
		formData.value[type] = [];
	}
	const tableCellClick = (row : any, column : any, cell : HTMLTableCellElement, event : Event) => {
		if(route.query.id){
			return;
		}
		types.value = '';
		//本次退货数量
		if (column.property === 'returnQuantity') {
			types.value = 'number';
		}
		//退货单价
		if (column.property === 'returnPrice') {
			types.value = 'number';
		}
		//退货订单明细
		if (column.property === 'orderDetailId') {
			types.value = 'select-icon';
			selectCell.value.option = [...orderDetailOption.value];
		}
		element.value = cell;
		//
		selectCell.value.id = row.id;
		selectCell.value.property = column.property;
		//
		levitationParams.value = row[column.property];

		setTimeout(() => {
			levitationRef.value.getElementInfo();
		}, 1);
		//
	}
	//改变
	const selectChange = (value : Array<any>, type : string, key : number) => {
		//所有下拉框的配置列表
		const typeList = [{
			type: 'customer', //哪一个下拉框，根据ref
			option: customerOption, //下拉列表选项
			indexVar: customerIndex, //当前选中项
			idVar: 'customerId', //当前id值
			blurRef: customer, //ref
			fun: getOrderListId
		}, {
			type: 'order', //哪一个下拉框，根据ref
			option: orderOption, //下拉列表选项
			indexVar: orderIndex, //当前选中项
			idVar: 'orderId', //当前id值
			blurRef: order, //ref
			fun: getOrderDetailList
		}, {
			type: 'inboundOrder', //哪一个下拉框，根据ref
			option: inboundOrderOption, //下拉列表选项
			indexVar: inboundOrderIndex, //当前选中项
			idVar: 'inboundOrderId', //当前id值
			blurRef: inboundOrder, //ref
		}];
		//
		handSelectChange(formData, typeList, value, type, key);
	}
	//tag改变
	const tagChange = (index : number, type : string) => {
		// if (type === 'returnStatusId') {
		// 	if (returnStatusIndex.value === index) {
		// 		formData.value[type] = null;
		// 		returnStatusIndex.value = -1;
		// 		return;
		// 	}
		// 	returnStatusIndex.value = index;
		// 	formData.value[type] = returnStatusTags.value[index].value;
		// }
		if (type === 'reasonReturnId') {
			if (reasonReturnIndex.value === index) {
				formData.value[type] = null;
				reasonReturnIndex.value = -1;
				return;
			}
			reasonReturnIndex.value = index;
			formData.value[type] = reasonReturnTags.value[index].value;
		}
	}
	//获取退货状态列表
	const getReturnStatusList = async () => {
		const data = await getShipments('return_status', 'tag');
		//
		console.log('getReturnStatusList --->', data);
		returnStatusTags.value = [];
		data.forEach((item : any, key : number) => {
			returnStatusTags.value.push({
				text: item.text,
				bg: item.bg,
				value: item.value
			});
			//
			if (formData.value.returnStatusId === item.value) {
				returnStatusIndex.value = key;
			}
		});
	}
	//获取客户列表
	const getCustomerList = async () => {
		const result = await request({
			url: '/login/selectCustomerAll',
			params: pageData.value,
		});
		//
		console.log('getCustomerList --->', result);
		customerOption.value = [];
		result.data.t.list.forEach((item : any, key : number) => {
			customerOption.value.push({
				label: `${item.customerName}（${item.customerRating}）${item.billingMethod}`,
				value: item.customerId,
				icon: UserFilled,
				color: '#82b51b'
			});
			if (formData.value.customerId === item.customerId) {
				formData.value.customer = [item.customerId];
				customerIndex.value = key;
				//
				getOrderListId(item.customerId);
			}
		});
	}
	//根据id获取订单信息
	const getOrderListId = async (id : number) => {
		orderOption.value = [];
		const result = await request({
			url: '/login/selectSaleOrderByCustomerId',
			params: {
				id
			}
		});
		//
		console.log('getOrderListId --->', result);
		result.data.t.forEach((item : any, key : number) => {
			orderOption.value.push({
				label: `${item.orderNumber}_${formatNumber(item.orderTotalAmount, '元')}_${item.status} | ${item.customer.customerName}`,
				value: item.orderId,
				icon: WalletFilled,
				color: '#82b51b'
			});
			if (formData.value.orderId === item.orderId) {
				formData.value.order = [item.orderId];
				orderIndex.value = key;
				//
				getOrderDetailList(item.orderId);
			}
		});
	}
	//获取退货原因列表
	const getReasonReturnList = async () => {
		const data = await getShipments('reason_return', 'tag');
		//
		console.log('getReasonReturnList --->', data);
		reasonReturnTags.value = data;
		data.forEach((item : any, key : number) => {
			if (formData.value.reasonReturnId === item.value) {
				reasonReturnIndex.value = key;
			}
		})
	}
	//根据id获取订单明细
	const getOrderDetailList = async (id : number) => {
		const result = await request({
			url: '/login/selectOrderDetailByOrderId',
			params: { id },
		});
		//
		console.log('getOrderDetailList --->', result);
		orderDetailOption.value = [];
		result.data.t.forEach((item : any, key : number) => {
			orderDetailOption.value.push({
				label: `${item.salesOrder.orderNumber}_${item.products.productName + item.products.model}`,
				value: item.orderDetailId,
				icon: CopyDocument,
				color: '#82b51b'
			});
		});
	}
	//根据id获取订单明细
	const getOrderDetil = async (id ?: string | number, key ?: number) => {
		if (!id) {
			return;
		}
		const result = await request({
			url: '/login/selectOrderDetail',
			params: {
				id
			}
		});
		//
		console.log('getOrderDetil --->', result);
		tableData[key] = mergeObjects(tableData[key], result.data.t);
		tableData[key].orderDetail = {
			label: `${result.data.t.salesOrder.orderNumber}_${result.data.t.products.productName + result.data.t.products.model}`,
			value: result.data.t.orderDetailId,
			icon: CopyDocument,
			color: '#82b51b'
		};
	}
	//提交表单
	const submitForm = async (formEl : FormInstance | undefined) => {
		if (!formEl) return;
		await formEl.validate(async (valid, fields) => {
			if (valid) {
				console.log('submitForm ---> ', formData.value);
				const data = { ...formData.value, returnDetails: [...tableData] };
				delete data.customer;
				delete data.order;
				let type = '';
				if (!route.query.id) {
					type = '/saveSalesReturn';
				} else {
					type = '/updateSalesReturn';
				}
				//
				const result = await request({
					url: '/login' + type,
					data: data,
					method: 'post'
				});
				//
				console.log('submitForm--->', result);
				//
				if (result.data.code === 200) {
					ElMessage.success({
						message: '操作成功！'
					});
				} else {
					ElMessage.error({
						message: result.data.msg
					});
				}
				// //
				setTimeout(() => {
					closeDialog();
					emits('update');
				}, 1);
			} else {
				//
				console.log('error submit!', fields);
			}
		});
	}
	//失去焦点 ***** 重要！重要！重要！
	const levitationBlur = () => {
		element.value = null;
	}
	//内容改变 *
	const levitationChange = (value : string | number) => {
		console.log('value --->', value);
		tableData.forEach((item : any, key : number) => {
			console.log('item.id --->', item.id, 'selectCell.value.id --->', selectCell.value.id);
			if (item.id === selectCell.value.id) {
				item[selectCell.value.property] = value;
				//
				if (selectCell.value.property === 'orderDetailId') {
					getOrderDetil(value, key);
				}
			}
		});
	}
	//滚动 *
	const handleScroll = (e : any) => {
		// console.log('handleScroll --->', e);
		if (element.value === null) return;
		levitationRef.value.getElementInfo();
	}
	defineExpose({
		openDialog
	});
</script>
<style>
	@import '../../../assets/css/my-form-item.css';

	.form-item-bg {
		background-color: #bfdfff;
	}

	.form-item-bg1 {
		background-color: #a5f2e5;
	}

	.my.el-input .el-input__inner {
		opacity: 0;
	}

	/*  */
	.avatar-uploader {
		width: 178px;
		height: 178px;
	}

	.avatar-uploader .avatar {
		width: 100%;
		height: 100%;
	}

	.avatar-uploader .el-upload {
		width: 100%;
		height: 100%;
		border: 1px dashed var(--el-border-color);
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
		transition: var(--el-transition-duration-fast);
	}

	.avatar-uploader .el-upload:hover {
		border-color: var(--el-color-primary);
	}

	.el-icon.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		text-align: center;
	}

	.el-scrollbar__view {
		display: block !important;
	}

	/*  */
</style>

<style scoped lang="scss">
	@import '../../../assets/css/index.scss';
</style>